package com.jvyou.framework.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jvyou.common.core.domain.entity.User;
import com.jvyou.common.core.domain.model.PageResult;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import com.jvyou.framework.service.UserService;
import com.jvyou.framework.mapper.UserMapper;
import com.jvyou.framework.domain.dto.UserDto;

/**
 * 用户表(User)表服务实现类
 *
 * @author 橘柚
 * @since 2025-05-29 17:20:41
 */
@RequiredArgsConstructor
@Service("userService")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    /**
     * 构建查询条件包装器
     * @param dto 查询参数
     * @return QueryWrapper
     */
    private QueryWrapper<User> getWrapper(UserDto dto) {
        QueryWrapper<User> ew = new QueryWrapper<>();
        return ew;
    }

    @Override
    public List<User> listUser(UserDto dto) {
        return list(getWrapper(dto));
    }

    @Override
    public PageResult<User> pageUser(UserDto dto) {
        IPage<User> page = new Page<>(dto.getCurrent(), dto.getPageSize());
        page = page(page, getWrapper(dto));
        return PageResult.success(page);
    }

}
